# TicTacToe.py
#
# Description: Draws a Tic Tac Toe board on the Turtle canvas
#              using the drawSquare(...) function.
#
# Author: Anne Lavergne
# Date: Feb. 14 2024

# Import the turtle library
import turtle

def drawSquare(aColour, aSideSize):
    """Draw a square of colour "aColour" and of side "sideSize"."""

    # Set the turtle's pen (tail) to "aColour"
    tt.color(aColour)
    
    # Tell the turtle to draw four sides
    # starting with the turtle facing east at (0,0)
    for side in range(4):  # 0,1,2,3
        tt.forward(aSideSize)
        tt.left(90)
    
    return



# ***Main part of my program

# Creates a graphics window "canvas"
canvas = turtle.Screen()

# Create a turtle named "tt"
tt = turtle.Turtle()

# Give a background color to "canvas"
canvas.bgcolor("aquamarine")

# Set "sideSize" to the size of each side of the square
sideSize = 150

# Set colour
colour = "black"

# Draw 3 rows of 3 squares: TicTacToe game
for y in [150,0,-150]:
    x = -150
    xOffset = 0
    # Draw 3 squares on this row
    for eachSquare in range(3):
        tt.penup()
        tt.goto(x+xOffset,y)
        tt.pendown()
        # Have "tt" drawing a square (angle is 90 by default)
        # of size "sideSize"
        drawSquare(colour, sideSize)
        xOffset += 150
    tt.penup()
    tt.home()


# Click on the canvas to exit
canvas.exitonclick()